package com.jsptpd.smartauth;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * jar need
 */
@RestController
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
@EnableCaching
@ServletComponentScan
@EnableScheduling
@EnableTransactionManagement(proxyTargetClass = true)
//@EnableDiscoveryClient
public class App {

    public static ApplicationContext applicationContext;

    @Value("${config.welcome}")
    private String welcomeWord;

    @RequestMapping(value={"/","/home"})
    ModelAndView home() {
        ModelAndView view = new ModelAndView();
        view.setViewName("welcome");
        view.addObject("result", welcomeWord);
        return view;
    }

    public static void main(String[] args) {
        applicationContext = SpringApplication.run(App.class, args);
    }
}
